home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / misc / wvware-mos.lha / bin / wvText < prev    next >
Text File  |  2002-05-07  |  1KB  |  57 lines

  1. #!/bin/sh
  2.  
  3. prefix=/gg
  4. exec_prefix=${prefix}
  5. datadir=${prefix}/share
  6. tmpdir=/tmp
  7.  
  8. # argument checking
  9. if [ ${#} -ne "2" ]; then
  10.     echo "Usage: ${0} <word document> <text output file>"
  11.     exit 1
  12. fi
  13.  
  14. # start out optimistic
  15. USING_LYNX=1
  16. which lynx >/dev/null 2>&1
  17. if [ ${?} -ne "0" ]; then
  18.     echo "Could not find required program 'lynx'"
  19.     echo "Not using lynx. Ouput will be pretty bad."
  20.     USING_LYNX=0
  21. fi
  22.  
  23. if [ ${USING_LYNX} -ne "0" ]; then
  24.  
  25.     # first, test for wvHtml
  26.     which wvHtml >/dev/null 2>&1
  27.     if [ ${?} -ne "0" ]; then
  28.            echo "Could not find required program 'wvHtml'"
  29.     exit 1
  30.     fi
  31.  
  32.     # intermediate file
  33.     TMP_FILE="wv$$.html"
  34.  
  35.     wvHtml "${1}" --targetdir="${tmpdir}" "${TMP_FILE}" >/dev/null 2>&1
  36.     if [ ${?} -ne "0" ]; then
  37.     echo "Could not convert into HTML"
  38.     exit 1
  39.     fi
  40.  
  41.     # lynx actually does quite well
  42.     TERM=vt100 lynx -dump -force_html "${tmpdir}/${TMP_FILE}" > "${2}"
  43.     if [ ${?} -ne "0" ]; then
  44.         echo "Could not convert into Text"
  45.         exit 1
  46.     fi
  47.  
  48.     # clean up
  49.     rm -f "${tmpdir}/${TMP_FILE}"
  50.  
  51. else
  52.     # fall back onto our cruddy output
  53.     # this is, admittedly, better than running
  54.     # 'strings' on the word document though :)
  55.     wvWare -x ${datadir}/wv/wvText.xml "${1}" > "${2}"
  56. fi
  57.